package Demo;

import java.util.Scanner;

public class Demo03 {
    private static volatile int flag = 0;
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread( () -> {
            while (flag == 0) {

            }
            System.out.println("t1结束");
        });

        Thread t2 = new Thread( () -> {
            Scanner scanner = new Scanner(System.in);
            int input = scanner.nextInt();
            flag = input;
            System.out.println("t2结束");
        });

        t1.start();
        t2.start();

        t1.join();
        t2.join();
    }
}
